import React,{useState,useEffect} from "react";
const GlobalContext = React.createContext();
function Callback(){
    const [name,setName] =useState("Mill")

    useEffect(() => {
        const timer= setInterval(() =>{
           
            setName(oldName =>oldName+"mill");
        },1000);
        return ()=>{
            clearInterval(timer)
        }
    },[]);


    return (
        <GlobalContext.Provider>
            <div >Reducer
                <Children name={name}/>
            </div>
        </GlobalContext.Provider>

    )
}
class Children extends React.Component {
    render() {
        return (
            <div>
            {this.props.name}
            </div>
        )
    }

}

export default Callback;